package com.my.buffers;

import java.io.*;

/**
 * @description:
 * @author: marshal
 * @date: 2021-08-24 3:40 PM
 */
public class BufferedOutputStreamTest {
    public static void main(String[] args) {
        try (
                var fis = new FileInputStream("file/bis.txt");
                var bis = new BufferedInputStream(fis);
                var fos = new FileOutputStream("file/bos.txt");
                var bos = new BufferedOutputStream(fos)
        ) {
            byte[] buff = new byte[1024];
            // he total number of bytes read into the buffer
            var hasRead = 0;
            while ((hasRead = bis.read(buff)) != -1) {
                bos.write(buff, 0, hasRead);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
